import { isEmpty } from 'lodash-es';

interface useUserSystemsReturnInterface {
  getUserSystems: () => void;
}

export const useUserSystems = (): useUserSystemsReturnInterface => {
  const microAppList = useMicroAppStore().microAppList;
  const getUserSystems = async () => {
    if (isEmpty(microAppList)) {
      const res = await userSystemsApi();
      if (res.ok) {
        useMicroAppStore().microAppList = res.data;
      }
    }
  };
  return {
    getUserSystems,
  };
};
